/**
 * Title RespEntity
 * Package com.ruoyi.common.app.core
 * Copyright 2024 www.hundsun.com All Rights Reserved.
 *
 * @author gd
 * @date 2024/9/9 1:13 AM
 * @version V5.1.2
 */
package com.ruoyi.common.app.core;

import com.ruoyi.common.core.domain.R;

/**
 * 公共响应头
 * ClassName RespEntity
 *
 * @author gd
 * @date 2024/9/9 1:13 AM
 */

public class RespEntity {

    /**
     * 用户token
     */
    private String token;

    /**
     * 响应码
     */
    private String code;

    /**
     * 响应信息
     */
    private String msg;

    /**
     * 响应实体
     */
    private Object obj;


    public static RespEntity ok() {
        return ok(null, null);
    }

    public static RespEntity ok(Object obj) {
        return ok(null,obj);
    }

    public static RespEntity ok(String token, Object obj) {
        RespEntity resp = new RespEntity();
        resp.code = "0000";
        resp.msg = "交易成功";
        if (null != token) {
            resp.token = token;
        }
        if (null != obj) {
            resp.setObj(obj);
        }
        return resp;
    }

    public static RespEntity fail() {
        return fail(null);
    }

    public static RespEntity fail(String msg) {
        return fail("9999", msg, null);
    }

    public static RespEntity fail(String code, String msg, Object obj) {
        RespEntity resp = new RespEntity();
        resp.code = code;
        resp.msg = msg;
        if (null != obj) {
            resp.setObj(obj);
        }
        return resp;
    }


    /**
     * 获取 响应码
     *
     * @return code 响应码
     */
    public String getCode() {
        return this.code;
    }

    /**
     * 设置 响应码
     *
     * @param code 响应码
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * 获取 响应信息
     *
     * @return msg 响应信息
     */
    public String getMsg() {
        return this.msg;
    }

    /**
     * 设置 响应信息
     *
     * @param msg 响应信息
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 获取 响应实体
     *
     * @return obj 响应实体
     */
    public Object getObj() {
        return this.obj;
    }

    /**
     * 设置 响应实体
     *
     * @param obj 响应实体
     */
    public void setObj(Object obj) {
        this.obj = obj;
    }

    /**
     * 获取 用户token
     *
     * @return token 用户token
     */
    public String getToken() {
        return this.token;
    }

    /**
     * 设置 用户token
     *
     * @param token 用户token
     */
    public void setToken(String token) {
        this.token = token;
    }
}